// @FileName  :t1.c
// @Time      :2024/4/25 18:50
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>

char buf[123], str[250], ans[250], remv[50];
int right, m, n, cnt = 1, rmvlen, len, cur;

int rmv(char cur) {
    if (rmvlen == 0) return 0;
    for (int i = 1; i <= rmvlen; i++) {
        if (cur == remv[i]) return 1;
    }
    return 0;
}

int getint(char *curr) {
    int num = 0;
    while (*curr <= '9' && *curr >= '0') {
        num = num * 10 + *curr - '0';
        curr++;
    }
    return num;
}

int getlen(int num) {
    if (num < 10) return 1;
    if (num < 100) return 2;
}

int main() {
    setbuf(stdout, NULL);
    gets(buf);
    gets(str);
    if (buf[cnt] == '-') {
        right = 1;
        cnt++;
    } else if (buf[cnt] == '[') {
        for (cnt = 2; buf[cnt] != ']'; cnt++)
            remv[++rmvlen] = buf[cnt];
        cnt++;
    }
//    printf("%s",buf);
//    printf("%s",str);
    m = getint(buf + cnt);
    cnt += getlen(m);
    n = getint(buf + cnt + 1);
    len = strlen(str);
    if (m > len) m = len;
    cnt = 0;
    if (right) {
        for (int i = 0; i < n - m; i++)
            printf("#");
        while (cnt < m) {
            if (rmv(str[cur])) {
                cur++;
            } else {
                printf("%c", str[cur]);
                cnt++;
                cur++;
            }
        }
    } else {
        while (cnt < m) {
            if (rmv(str[cur])) {
                cur++;
            } else {
                printf("%c", str[cur]);
                cnt++;
                cur++;
            }
        }
        for (int i = 0; i < n - m; i++)
            printf("#");
    }


}
